# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html

from tutorial.settings import logger
import json

class TutorialPipeline(object):
    def process_item(self, item, spider):
        return item


class QuotesPipeline(object):
    def open_spider(self, spider):
        self.file = open('items.json', 'w', encoding='utf-8')

    def process_item(self, item, spider):
        logger.info('myprint process_item')
        logger.info(type(item))
        context = json.dumps(dict(item),ensure_ascii=False) + '---行数\n'
        self.file.write(context)

    def close_spider(self,spider):
        self.file.close()
